<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	<title></title>
	<script type="text/javascript" src="../../js/boot.js"></script>
</head>

<body>
	<div style="width:100%;">
		<fieldset id="fd1" style="width: 97%; margin-bottom: 4px;">
			<legend><span>查询条件</span></legend>
			<div id="queryForm" class="fieldset-body">
				<table class="form-table" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="form-label">
							<span>项目名称：</span>
							<input name="projectName" class="mini-textbox" style="width: 150px" />
							<input name="projectName_link" value="like" class="mini-hidden" style="width: 150px" />
							<a class="mini-button" onclick="doSearch">查询</a>
							<a class="mini-button" onclick="doEdit('add')">新增</a>
							<a class="mini-button" onclick="doEdit('update')">修改</a>
						</td>
					</tr>
				</table>
			</div>
		</fieldset>

	</div>
	<div style="width:100%;height:86%;">
		<div class="mini-fit">
			<div id="datagrid" class="mini-datagrid" style="width:100%;height:100%;" pageSize="20" idField="instID" allowResize="true">
			</div>
		</div>
	</div>

	<!-- 计算需要显示的控件数量 -->
	<!-- 根据控件数量计算窗体的高度 -->
	<div id="detailWin" class="mini-window" title="" style="width:800px;height:540px;" showMaxButton="true" showCollapseButton="true" showShadow="true"
		showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">
		<div id="detailForm" style="padding:10px;">
			<input name="id" class="mini-hidden" />
			<table align="center">
				<tr>
					<td align="right">项目名称：</td>
					<td align="left"><input id="projectName" name="projectName" class="mini-textbox" width="260"></td>
					<td align="right">公众号名称：</td>
					<td align="left"><input name="publicName" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">APP_ID：</td>
					<td align="left"><input name="appId" class="mini-textbox" width="260"></td>
					<td align="right">公众号二维码：</td>
					<td align="left"><input name="QRCode" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">公众号原始ID：</td>
					<td align="left"><input name="originalID" class="mini-textbox" width="260"></td>
					<td align="right">公众号级别：</td>
					<td align="left"><input name="publicLevel" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">公众号开发者ID：</td>
					<td align="left"><input name="developerID" class="mini-textbox" width="260"></td>
					<td align="right">APP_SECRET：</td>
					<td align="left"><input name="appSecret" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">微信TOKEN：</td>
					<td align="left"><input name="token" class="mini-textbox" width="260"></td>
					<td align="right">微信AES_KEY：</td>
					<td align="left"><input name="aesKey" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">商户微信支付apiKey：</td>
					<td align="left"><input name="apiKey" class="mini-textbox" width="260"></td>
					<td align="right">商户号ID：</td>
					<td align="left"><input name="mchId" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">keyPath：</td>
					<td align="left"><input name="keyPath" class="mini-textbox" width="260"></td>
					<td align="right">微信白名单：</td>
					<td align="left"><input name="whiteList" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">微信服务器配置启用地址：</td>
					<td align="left"><input name="configAddress" class="mini-textbox" width="260"></td>
					<td align="right">微信支付目录配置URL：</td>
					<td align="left"><input name="directoryPath" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">借权URL：</td>
					<td align="left"><input name="borrowRightUrl" class="mini-textbox" width="260"></td>
					<td align="right">微信支付：</td>
					<td align="left"><input name="mchKey" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">子商户公众账号ID：</td>
					<td align="left"><input name="subAppId" class="mini-textbox" width="260"></td>
					<td align="right">子商户号ID：</td>
					<td align="left"><input name="subMchId" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">日志处理类：</td>
					<td align="left"><input name="logHandlerClassName" class="mini-textbox" width="260"></td>
					<td align="right">消息处理类：</td>
					<td align="left"><input name="msgHandlerClassName" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">微信关注处理类：</td>
					<td align="left"><input name="subscribeHandlerClassName" class="mini-textbox" width="260"></td>
					<td align="right">取消关注处理类：</td>
					<td align="left"><input name="unSubscribeHandlerClassName" class="mini-textbox" width="260"></td>
				</tr>
				<tr>
					<td align="right">服务器地址：</td>
					<td align="left"><input name="serverUrl" class="mini-textbox" width="260"></td>
					<td align="right">使用中：</td>
					<td align="left"><input name="inUsed" class="mini-combobox" textField="text" valueField="id" data="CONST.get('useState')"></td>
				</tr>
				<!-- 如果是单数就补充缺失部分 -->
			</table>
		</div>
		<div property="footer" style="text-align:center;padding:5px;padding-right:15px;">
			<a class="mini-button" iconCls="icon-save" onClick="doSave()">保存</a>
			<a class="mini-button" iconCls="icon-cancel" onClick="cancel()">取消</a>
		</div>
	</div>
</body>

<script type="text/javascript">
	miniInit();

	var queryForm = new mini.Form("#queryForm");
	var detailForm = new mini.Form("#detailForm");
	var win = mini.get("detailWin");

	var datagrid = mini.get("datagrid");
	datagrid.set({
		url: http.getUrl("/weixin/config/list.do"),
		columns: [{
			type: "indexcolumn"
		}, {
			field: "projectName",
			width: 100,
			headerAlign: "center",
			allowSort: true,
			header: "项目名称"
		}, {
			field: "publicName",
			width: 100,
			headerAlign: "center",
			header: "公众号名称"
		}, {
			field: "appId",
			width: 100,
			headerAlign: "center",
			header: "APP_ID"
		}, {
			field: "appSecret",
			width: 100,
			headerAlign: "center",
			header: "APP_SECRET"
		}, {
			field: "token",
			width: 100,
			headerAlign: "center",
			header: "TOKEN"
		}, {
			field: "inUsed",
			width: 100,
			headerAlign: "center",
			header: "使用中",
			type: "comboboxcolumn",
			editor: { type: "combobox", data: CONST.get('useState') }
		}]
	});

	// 表单与表格绑定数据
	var db = new mini.DataBinding();
	db.bindForm("detailForm", datagrid);

	doSearch();
	function doSearch() {
		var data = queryForm.getData(true, false);
		datagrid.load(data, null, miniui.showLoadErrorMessageBox);
	}

	function doEdit(type) {
		// debugger
		if (type == 'add') {
			win.setTitle("新增");
			mini.get("projectName").setEnabled(true);
			datagrid.clearSelect(false);
			detailForm.reset();
		} else {
			if (datagrid.getSelected() == undefined) {
				mini.alert("请先选择要编辑的数据!", "提示", null);
				return;
			}
			win.setTitle("修改");
			mini.get("projectName").setEnabled(false);
			detailForm.setData(datagrid.getSelected());
		}
		win.showAtPos('center', 'middle');
	}

	function doSave() {
		if (!detailForm.validate()) {
			return;
		}
		mini.mask({
			el: document.body,
			cls: 'mini-mask-loading',
			html: '数据保存中...'
		});
		var data = detailForm.getData();
		debugger
		data.admin = "test";
		http.post("/weixin/config/save.do", data, function (page) {
			mini.unmask();
			win.hide();
			mini.alert("保存成功", "提示", null);
			datagrid.reload();
		});
	}

	function cancel() {
		win.hide();
	}
</script>

</html>